package com.kaishengit.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.kaishengit.dao.TaskDao;
import com.kaishengit.dao.UserDao;
import com.kaishengit.pojo.Task;
import com.kaishengit.pojo.User;
import com.kaishengit.util.DateUtil;

@Service
@Transactional
public class TaskService {
	@Autowired
	private TaskDao dao;
	
	@Autowired
	private UserDao userDao;

	public void save(Task task) {
		User u = userDao.get(task.getUser().getId()); 
		
		task.setCreatetime(DateUtil.getNow());
		task.setStarttime(DateUtil.getDay());
		
		task.setEndtime(DateUtil.getEndtime(task.getTime()));
		
		
		task.setUser(u);
		dao.save(task);
		
	}
}
